package com.cnbm.modules.messagequeue.controller;


import com.cnbm.modules.messagequeue.producter.RabbitSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2020/10/29 16:16
 */
@RestController
@RequestMapping("/mq")
public class MessageQueueController {
    @Autowired
    private RabbitSender rabbitSender;

    @GetMapping("/send10")
    public String send10() throws Exception {
        for(int i=0;i<10;i++){
            Map<String,Object> objectMap = new HashMap<>();
            objectMap.put("attr1","12345");
            objectMap.put("attr2","ABCDE");
            String s = "ABC ABC"+i;
            rabbitSender.send(s,objectMap);
            Thread.sleep(30);
        }
        return "ok";
    }
}
